package cn.lijiajia3515.cairo.system.modules.file;

import cn.lijiajia3515.cairo.core.page.Page;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public interface FileInterface {
	String PREFIX = "/api/file";

	/**
	 * 创建文件夹
	 *
	 * @param param param
	 */
	@PostMapping(path = PREFIX + "/folder/save")
	void createFolder(@RequestBody SaveFolderParam param);

	/**
	 * 重名
	 *
	 * @param param param
	 */
	@PutMapping(path = PREFIX + "/folder/rename")
	void renameFolder(@RequestBody RenameFolderParam param);

	/**
	 * 删除 文件夹
	 *
	 * @param param param
	 */
	@DeleteMapping(path = PREFIX + "/folder/delete")
	void deleteFolder(@RequestBody DeleteFolderParam param);

	/**
	 * 查找文件夹
	 *
	 * @param param param
	 * @return folder tree list
	 */
	@GetMapping(path = PREFIX + "/folder/find_tree")
	List<Folder> treeFindFolder(@RequestBody FindFolderParam param);


	//file
	@PostMapping(path = PREFIX + "/upload", produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	List<File> uploadFile(@RequestParam(name = "Path", defaultValue = "/") String folderPath,
						  @RequestPart(name = "Files") MultipartFile[] files);

	/**
	 * 文件 查询(分页)
	 *
	 * @param param param
	 * @return file list page
	 */
	@PostMapping(path = PREFIX + "/find_page")
	Page<File> pageFindFile(@RequestBody FindFileParam param);


	/**
	 * 文件查询
	 *
	 * @param param param
	 * @return file list
	 */
	@PostMapping(path = PREFIX + "/find")
	List<File> findFile(@RequestBody FindFileParam param);

}
